package com.wlz.servlet;

import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.*;
import io.netty.util.CharsetUtil;

public interface HttpServlet {

    FullHttpResponse get(FullHttpRequest request);

    FullHttpResponse post(FullHttpRequest request);

    default FullHttpResponse send(String content, HttpResponseStatus status){
        FullHttpResponse response =
                new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,status,
                        Unpooled.copiedBuffer(content, CharsetUtil.UTF_8));
        response.headers().set(HttpHeaderNames.CONTENT_TYPE,
                "text/plain;charset=UTF-8");
//        ctx.writeAndFlush(response)
//                .addListener(ChannelFutureListener.CLOSE);
        return response;
    }
}
